package com.projetIE.prudhomme_duisit;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

/**
 * <p>
 * Java class for anonymous complex type.
 * 
 * <p>
 * The following schema fragment specifies the expected content contained within
 * this class.
 * 
 * <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="client" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *         &lt;element name="pays" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         &lt;element name="ville" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "client", "pays", "ville" })
@XmlRootElement(name = "postRequestRequest")
public class PostRequestRequest {
	
	@XmlElement(required = true)
	protected String	client;
	
	protected String	pays;
	
	protected String	ville;
	
	/**
	 * Gets the value of the client property.
	 * 
	 * @return possible object is {@link String }
	 * 
	 */
	public String getClient() {
		return client;
	}
	
	/**
	 * Sets the value of the client property.
	 * 
	 * @param value
	 *            allowed object is {@link String }
	 * 
	 */
	public void setClient(String value) {
		this.client = value;
	}
	
	/**
	 * Gets the value of the pays property.
	 * 
	 * @return possible object is {@link String }
	 * 
	 */
	public String getPays() {
		return pays;
	}
	
	/**
	 * Sets the value of the pays property.
	 * 
	 * @param value
	 *            allowed object is {@link String }
	 * 
	 */
	public void setPays(String value) {
		this.pays = value;
	}
	
	/**
	 * Gets the value of the ville property.
	 * 
	 * @return possible object is {@link String }
	 * 
	 */
	public String getVille() {
		return ville;
	}
	
	/**
	 * Sets the value of the ville property.
	 * 
	 * @param value
	 *            allowed object is {@link String }
	 * 
	 */
	public void setVille(String value) {
		this.ville = value;
	}
	
	/**
	 * @return Document
	 */
	public Document generatedDom() {
		DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
		DocumentBuilder docBuilder;
		Document doc = null;
		try {
			docBuilder = dbfac.newDocumentBuilder();
			
			doc = docBuilder.newDocument();
			
			doc.setXmlVersion("1.0");
			
			Element root = doc.createElement("requete-meteo");
			
			Element client = doc.createElement("client");
			client.setTextContent(getClient());
			root.appendChild(client);
			
			Element country = doc.createElement("pays");
			if (pays != null)
				country.setTextContent(getPays());
			root.appendChild(country);
			
			Element city = doc.createElement("ville");
			if (ville != null)
				city.setTextContent(getVille());
			root.appendChild(city);
			
			doc.appendChild(root);
			
		} catch (ParserConfigurationException e) {
			e.printStackTrace();
		}
		return doc;
	}
	
}
